'''
Created on Dec 6, 2012

@author: shraybansal
'''

def scoreDict(gest):
    """Score Dictionary"""
    gestureNames = ['Triangle' , 'Window_Open' , 'Window_Close' , 'Fire_On', 'Fire_Off', 'Throw_Money', 'Slap', 'W', 'Swing_Phone',
                    'Tap_Phone', 'Orient', 'Multi_Finger_Snap', 'Flick_Air', 'Door_Close']
                     
    gestureScores = [0.646606959590664 , 0.337574616956667 , 0.206060275388746 , 0.216788521133693 , 0.557670355893116 ,    
                     0.503149974974571 , 0.821100703392535 , 0.30661128579679 , 1 , 0 , 0.472536449496682 , 0.41194327427083,    
                     0.29626772148345 , 0.21286854667255]
    
    gestScores={}
    for i in range(len(gestureScores)):
        gestScores[gestureNames[i]]= gestureScores[i]
    return gestScores[gest]


def findPos(score, gesName):
    gestureNames = ['Triangle' , 'Window_Open' , 'Window_Close' , 'Fire_On', 'Fire_Off', 'Throw_Money', 'Slap', 'W', 'Swing_Phone',
                    'Tap_Phone', 'Orient', 'Multi_Finger_Snap', 'Flick_Air', 'Door_Close']
    scoreList = [score]
    for name in gestureNames:
        if not name==gesName:
            scoreList.append(scoreDict(name))
    scoreList.sort()
    for i in range(len(scoreList)):
        if(scoreList[i]==score):
            return i

def errorScore(gesName, score):
    old_pos = findPos(scoreDict(gesName), gesName)
    new_pos = findPos(score, gesName)
    return abs(new_pos-old_pos)


